#include "DefaultFileStream.h"

CDefaultFileStream::CDefaultFileStream(void):m_pFile(NULL),m_bRead(false)
{
}

CDefaultFileStream::~CDefaultFileStream(void)
{
}
size_t	CDefaultFileStream::_fread(void * _DstBuf,size_t _ElementSize, size_t _Count)
{
	if(!m_bRead)
	{
		return 0;
	}

	return fread(_DstBuf,_ElementSize,_Count,m_pFile);
}
size_t	CDefaultFileStream::_fwrite(const void * _Str,size_t _Size, size_t _Count)
{
	if(m_bRead)
	{
		return 0;
	}

	return fwrite(_Str,_Size,_Count,m_pFile);
}
bool	CDefaultFileStream::_fopen(const char * _FileData , int nSize,bool bRead)
{
	m_bRead = bRead;
	return true;
}
bool	CDefaultFileStream::_fopen(const char * _Filename, bool bRead)
{
	m_bRead = bRead;
	if(bRead)
	{
		m_pFile = fopen( _Filename,"rb"  );
	}
	else
	{
		m_pFile = fopen( _Filename,"wb" );
	}
	if( !m_pFile )
	{
		return false;
	}
	return true;
}
int		CDefaultFileStream::_fclose()
{
	int nRes = 0;
	if( m_pFile )
	{
		nRes = fclose( m_pFile );
		m_pFile = 0;
	}
	return nRes;
}
